package org.nfIt;

import org.nfIt.dao.BookDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import java.awt.print.Book;

/**
 * ClossName:App
 * Pakage:org.nfIt
 * Description
 *
 * @Author L
 * @Create 2024/5/3 0:07
 * @Version 2023.1.3
 */
public class App {
    public static void main(String[] args) {

        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");


//        ApplicationContext context= new FileSystemXmlApplicationContext("D:\\idea-wenjian\\maven-Spring-demo08\\src\\main\\resources\\applicationContext.xml");

        //方式一：使用bean名称获取
        BookDao booDao = (BookDao) context.getBean("BooDao");

        //方式二：使用bean名称获取并指定类型
        BookDao bookDao = context.getBean("BookDao", BookDao.class);

        //方式三：使用bean类型获取
        BookDao bookDao1 = context.getBean(BookDao.class);

        booDao.say();
    }
}
